<template>
  <van-cell
      is-link to="/safe"
      title="账号与安全"
  >
    <template #icon >
      <svg-icon icon-name="icon-zhanghaoyuanquan" class="left-icon"  ></svg-icon>
    </template>
  </van-cell>
  <van-cell
      is-link to="/user/team/create"
      title="切换账号"
  >
    <template #icon >
      <svg-icon icon-name="icon-qiehuanjiaose" class="left-icon"  ></svg-icon>
    </template>
  </van-cell>
  <van-cell
      is-link to="/user/team/create"
      title="帮助与反馈"
  >
    <template #icon >
      <svg-icon icon-name="icon-bangzhuyufankui" class="left-icon"  ></svg-icon>
    </template>
  </van-cell>
  <van-cell
      title="退出登录"
      class="logout-cell"
      @click="onClick"
  >
    <template #icon >
      <svg-icon icon-name="icon-guanbi" class="logout-icon"  ></svg-icon>
    </template>
  </van-cell>
</template>


<script setup lang="ts">
import {useRouter} from "vue-router";

const router = useRouter();
import SvgIcon from "../components/SvgIcon.vue";
import myAxios from "../plugins/myAxios";
import {Toast} from "vant";

const onClick = async () => {
  const res = await myAxios.post('/user/logout');
  console.log(res, '用户退出登录');
  if (res.code === 0 && res.data) {
    Toast.success('退出登录成功');
    // 跳转到之前的页面
    /*const redirectUrl = route.query?.redirect as string ?? '/uer/login';
    window.location.href = redirectUrl;*/
    await router.push('/user/login');
  } else {
    Toast.fail('退出登录失败');
  }
};

</script>



<style scoped>
.left-icon{
  margin-top: 4px;
  margin-right: 4px;
}
.logout-cell {
  /*  text-align: center;*/
  color: #d86262;
  height: 120px;
  margin-top: 9px;
}
.logout-icon{
  color: #d86262;
  margin-left: 38%;
  margin-right: 5px;
  margin-top: 4px;
}

</style>